package com.open.demo.mvi

import kotlinx.coroutines.flow.collect

/**
 *
 * @Author: hailong.qiu 356752238@qq.com
 * @Maintainer: hailong.qiu 356752238@qq.com
 * @Date: 2022/6/10
 * @Copyright: 2022 www.andriodtvdev.com Inc. All rights reserved.
 */
class ImageView {


    private val viewModel by lazy { ImageViewModel() }

    init {

    }

    suspend fun test() {
        viewModel.state.collect {
            when (it) {
                is ImageState.LoadingState-> {
                }
                is ImageState.ErrorState-> {
                    it.error
                }
                is ImageState.NextPage-> {
                    showNextPage(it.json)
                }
                is ImageState.FinishState-> {
                }
            }
        }
        //
        viewModel.userIntent.send(ImageIntent.ImageData(3))
    }

    fun showNextPage(json:String) {
        // 刷新页码数据
    }

}